/* 
 * Quechua - the lightweight data mining framework
 *
 * Copyright (C) 2012 Marek Denis <quechua@octogan.net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef POSTPROCLOG_H
#define POSTPROCLOG_H

#include "../../../include/types.h"
#include "../../../include/interface-common.h"
#include "../../../include/interface-logger.h"
#include "../../data/types.h"
#include "../../data/dionaeaconnections.h"
#include "../../data/indextransactions.h"
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>

using std::exception;
using std::nothrow;

class PostProcessorLogger : public Logger {
    struct credentials_s {
        string_t user;
        string_t password;
        string_t hostname;
        string_t database;
    };
 protected: 
        dbconnection_t* connection;
        credentials_s credentials;
        static char buf[1024];
        /* internal methods */
        char* quotize(char* dst, size_t n, const char* src);
        index_t get_oid(dbwork_t* w);
        void insert_into_operation(dbwork_t* w, index_t& oid, const string_t& from, const string_t& to);
        void insert_into_preprocesstest(dbwork_t* w,index_t& oid,DionaeaConnections::unindexedTransaction* txn);
 public:
    PostProcessorLogger();
    virtual ~PostProcessorLogger();

    bool load_misc_conf(const setting_t& misc);
   
    bool prepare();
    bool stop();
    void logwork(datapack_ptr data);

}; // PostProcessorLogger

extern "C" Logger* create_logger() {
    return new PostProcessorLogger();
};

#endif 
